"ui";

importClass(android.content.Intent);
importClass(android.net.Uri);
importClass(com.afollestad.materialdialogs.MaterialDialog);
importPackage(java.net);
importPackage(java.io);
importPackage(java.lang);

function Get(path){
var url=new URL(path);
var conn=url.openConnection();
conn.setConnectTimeout(3000);
conn.setRequestMethod("GET");
var isn=conn.getInputStream();
var is=new InputStreamReader(isn);
var buf=new BufferedReader(is);
var res=new StringBuilder();
while((str=buf.readLine())!=null)
{
res.append(str);
}
return res.toString();
}

new MaterialDialog.Builder(activity)
    .title("IP定位")
    .input("输入IP地址...", "", function(dialog, input){
new java.lang.Thread(function(){
input=input+"";
clearConsole();
openConsole();
log("IP定位");
print(iplocation(input));
}).start();
    })
    .positiveText("确定")
    .dismissListener(function(dialog){
        activity.finish();
    })
    .show();

function iplocation(ipa){
var _$=["\x42\x79\x20\x44\x61\x20\x5a\x68\x61\x6e\x67\x20\x51\x51\x3a\x33\x32\x35\x35\x32\x37\x33\x32\n\x49\x50\u6570\u636e\u6765\u81ea\u767e\u5ea6\x4c\x42\x53\u4e91\n\n","\x49\x50\u5730\u5740\u6709\u8bef\uff0c\u8bf7\u8f93\u5165\u6b63\u786e\u7684\x49\x50\x76\x34\u5730\u5740\u3002","\x68\x74\x74\x70\x73\x3a\x2f\x2f\x61\x70\x69\x2e\x6d\x61\x70\x2e\x62\x61\x69\x64\x75\x2e\x63\x6f\x6d\x2f\x68\x69\x67\x68\x61\x63\x63\x69\x70\x6c\x6f\x63\x2f\x76\x31\x3f\x71\x63\x69\x70\x3d","\x26\x61\x6b\x3d\x6d\x41\x43\x67\x74\x57\x4b\x78\x68\x41\x6e\x52\x4f\x71\x58\x78\x46\x79\x76\x48\x54\x49\x64\x39\x6b\x4f\x48\x35\x73\x39\x74\x36\x26\x71\x74\x65\x72\x6d\x3d\x26\x65\x78\x74\x65\x6e\x73\x69\x6f\x6e\x73\x3d\x31\x26\x63\x6f\x6f\x72\x64\x3d\x62\x64\x30\x39","\x2c","\x49\x50\x3a","\x20\u5b9a\u4f4d\u6210\u529f\uff1a\n\u5730\u5740\x3a","\n\u534a\u5f84\x3a","\n\u53ef\u4fe1\u5ea6\x3a","\n\u5730\u56fe\u94fe\u63a5\uff1a\x68\x74\x74\x70\x3a\x2f\x2f\x61\x70\x69\x2e\x6d\x61\x70\x2e\x62\x61\x69\x64\x75\x2e\x63\x6f\x6d\x2f\x6d\x61\x72\x6b\x65\x72\x3f\x6c\x6f\x63\x61\x74\x69\x6f\x6e\x3d","\x26\x74\x69\x74\x6c\x65\x3d","\x26\x63\x6f\x6e\x74\x65\x6e\x74\x3d\x49\x50\x3a","\x26\x6f\x75\x74\x70\x75\x74\x3d\x68\x74\x6d\x6c\x26\x63\x6f\x6f\x72\x64\x5f\x74\x79\x70\x65\x3d\x62\x64\x30\x39","\x49\x50\x3a","\x20\u5b9a\u4f4d\u5931\u8d25\uff1a\n\u9519\u8bef\u7801\x3a"];var a=_$[0];if(ipa["\x6d\x61\x74\x63\x68"](/^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$/)==null){a+=_$[1]}else{var b=Get(_$[2]+ipa+_$[3]);b=JSON["\x70\x61\x72\x73\x65"](b);if(b["\x72\x65\x73\x75\x6c\x74"]["\x65\x72\x72\x6f\x72"]==0xa1){var c=b["\x63\x6f\x6e\x74\x65\x6e\x74"]["\x66\x6f\x72\x6d\x61\x74\x74\x65\x64\x5f\x61\x64\x64\x72\x65\x73\x73"];var d=b["\x63\x6f\x6e\x74\x65\x6e\x74"]["\x6c\x6f\x63\x61\x74\x69\x6f\x6e"]["\x6c\x61\x74"]+_$[4]+b["\x63\x6f\x6e\x74\x65\x6e\x74"]["\x6c\x6f\x63\x61\x74\x69\x6f\x6e"]["\x6c\x6e\x67"];var e=b["\x63\x6f\x6e\x74\x65\x6e\x74"]["\x72\x61\x64\x69\x75\x73"];var f=b["\x63\x6f\x6e\x74\x65\x6e\x74"]["\x63\x6f\x6e\x66\x69\x64\x65\x6e\x63\x65"];a+=_$[5]+ipa+_$[6]+c+_$[7]+e+_$[8]+f+_$[9]+d+_$[10]+encodeURI(c)+_$[11]+ipa+_$[12]}else{a+=_$[13]+ipa+_$[14]+b["\x72\x65\x73\x75\x6c\x74"]["\x65\x72\x72\x6f\x72"]}};return a;}